home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_flash_m.cog < prev    next >
Text File  |  1998-02-25  |  9KB  |  342 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_FLASH_M.COG
  4. #
  5. # WEAPON 14 Script - Flash Bomb
  6. #
  7. # Functions kind of like the thermal detonator, except in that it creates a
  8. # blinding flash instead of an explosion.
  9. #
  10. # - Not affected by MagSealed sectors/surfaces.
  11. #
  12. # [YB & CYW] + [RF]
  13. #
  14. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  15. # ========================================================================================
  16.  
  17.  
  18.  
  19.  
  20.  
  21. symbols
  22.  
  23. model       povModel=flsv.3do             local
  24. model       povModel_m=flsv_m.3do         local
  25. model       weaponMesh=flsg.3do           local
  26.  
  27. keyframe    mountAnim=flsvmnt.key         local
  28. keyframe    dismountAnim=flsvdis.key      local
  29. keyframe    povFireAnim=flsvpst1.key      local
  30. keyframe    prePOVThrowAnim=flsvpre1.key  local
  31. #keyframe   preThrowAnim=kyrthro0.key     local
  32. keyframe    holsterAnim=kyhlstr.key       local
  33.  
  34. template    projectile=+flashbomb1        local
  35. template    projectile1=+flashbomb2       local
  36. template    projectileB=+dudflash         local
  37.  
  38. sound       throwSound=ThermalThrow01.wav local
  39. sound       clickSound=ThermClick01.wav   local
  40. sound       clickSound2=ThermClick02.wav  local
  41. sound       loopSound=ThermLoop01.wav     local
  42.  
  43. flex        delayTime=1.0                 local
  44. flex        throwWait=0.8                 local
  45. flex        mountWait                     local
  46. flex        autoAimFOV=10                 local
  47. flex        autoAimMaxDist=5              local
  48. flex        holsterWait                   local
  49.  
  50. thing       player                        local
  51. thing            victim                                local
  52.  
  53. int         preThrowTrack                 local
  54. int         selectTrack                   local
  55. int         prePOVThrowTrack              local
  56. int         mode                          local
  57. int         cocked=0                      local
  58. int         holsterTrack                  local
  59.  
  60. int         selectMode=1                  local
  61.  
  62. message     startup
  63. message     activated
  64. message     deactivated
  65. message     selected
  66. message     deselected
  67. message     autoselect
  68. message     timer
  69. message     newplayer
  70. message     splash
  71. message        user0
  72.  
  73. end
  74.  
  75. # ========================================================================================
  76.  
  77. code
  78.  
  79. startup:
  80.    // Setup delays and variables.
  81.    mountWait    = GetKeyLen(mountAnim);
  82.  
  83.    preThrowTrack=-1;
  84.    selectTrack=-1;
  85.    prePOVThrowTrack=-1;
  86.  
  87.    Return;
  88.  
  89. # ........................................................................................
  90.  
  91. activated:
  92.    player = GetSourceRef();
  93.    mode = GetSenderRef();
  94.    if (mode > 1)
  95.       Return;
  96.  
  97.    PlaySoundThing(clickSound[mode], player, 1.0, -1.0, -1.0, 0x80);
  98.  
  99.    // Cock arm back for throw.
  100.    if(preThrowTrack == -1 && prePOVThrowTrack == -1)
  101.    {
  102.       prePOVThrowTrack = jkPlayPOVKey(player, prePOVThrowAnim, 1, 0x14);
  103.       preThrowTrack = PlayMode( player, 38 );
  104.       ActivateWeapon(player, 0, mode);
  105.    }
  106.    Return;
  107.  
  108. # ........................................................................................
  109.  
  110. deactivated:
  111.    player = GetSourceRef();
  112.    mode = GetSenderRef();
  113.  
  114.    delayTime = DeactivateWeapon(player, mode);        // allow activated messages again.
  115.  
  116.         // Don't throw if controls are disabled.
  117.    if (!(GetActorFlags(player) & 0x200000))
  118.     {
  119.         // Make sure both keys are up before continuing.
  120.         if (GetCurWeaponMode() != -1)
  121.             Return;
  122.     
  123.         // Set maximum scale factor (2 second hold.)
  124.         if(delayTime > 2)
  125.             delayTime = 2;
  126.     
  127.         // Restrict throw type.
  128.         mode = 1;
  129.     
  130.         // Set minimum scale factor
  131.         if(mode == 0)
  132.         {
  133.             if(delayTime < 0.7) delayTime = 0.7;
  134.         }
  135.         else
  136.         {
  137.             if(delayTime < 0.25) delayTime = 0.25;
  138.         }
  139.     
  140.         if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  141.         {
  142.             jkStopPOVKey(player, prePOVThrowTrack, 0);
  143.             StopKey(player, preThrowTrack, 0);
  144.             preThrowTrack = -1;
  145.             prePOVThrowTrack = -1;
  146.         }
  147.     
  148.         if (GetInv(player, 93))
  149.         {
  150.             mode = 2;
  151.             SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  152.         }
  153.     
  154.         // Throw the appropriate detonator.
  155.         SetPOVShake('0.0 -.003 0.0', '0.5 0.0 0.0', .05, 40.0);
  156.         jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  157.         PlaySoundThing(throwSound, player, 1.0, 0.5, 2.5, 0x80);
  158.         SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  159.         FireProjectile(player, projectile[mode], -1, 15, '0.05 0 0', '0 0 0', delayTime, 0x1, 0.0, 0.0);
  160.         ChangeInv(player, GetWeaponBin(14), -1.0);
  161.         SetMountWait(player, throwWait);
  162.     
  163.         // If out of ammo try to autoswitch to another weapon
  164.         // if autoswitch is enabled else just switch to fists.
  165.         if(GetInv(player, GetWeaponBin(14)) < 1)
  166.         {
  167.             if(GetAutoSwitch() & 1)
  168.             {
  169.                 SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  170.             }
  171.             else
  172.             {
  173.                 SelectWeapon(player, 1);
  174.             }
  175.         }
  176.     }
  177.     else
  178.     {
  179.         if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  180.         {
  181.             jkStopPOVKey(player, prePOVThrowTrack, 0);
  182.             StopKey(player, preThrowTrack, 0);
  183.             preThrowTrack = -1;
  184.             prePOVThrowTrack = -1;
  185.         }
  186.     }
  187.  
  188.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  189.    SetTimerEx(throwWait, 0, 0, 0);
  190.  
  191.    Return;
  192.  
  193. # ........................................................................................
  194.  
  195. timer:
  196.    if (GetSenderId() == 0)
  197.    {
  198.       // Start waggling after the throw.
  199.       jkSetWaggle(player, '10.0 7.0 0.0', 350);
  200.    }
  201.    else
  202.    if (GetSenderId() == 2)
  203.    {
  204.       StopKey(player, holsterTrack, 0.0);
  205.    }
  206.    else
  207.    if (GetSenderId() == 11)
  208.    {
  209.         if(GetThingSignature(GetParam(1)) == GetParam(0))
  210.             ClearActorFlags(GetParam(1), 0x800);
  211.     }
  212.    Return;
  213.  
  214. # ........................................................................................
  215.  
  216. selected:
  217.    player = GetSourceRef();
  218.  
  219.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  220.  
  221.    // Play external mounting animation
  222.    PlayMode(player, 40);
  223.  
  224.    // Setup the meshes and models.
  225.     if (GetInv(player, 67) == 0.0)
  226.         jkSetPOVModel(player, povModel);        // Kyle hand
  227.     else
  228.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  229.    SetArmedMode(player, 0);
  230.    jkSetWeaponMesh(player, weaponMesh);
  231.  
  232.    // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
  233.    // The animation is held at the last frame after it is played.
  234.    selectTrack = jkPlayPOVKey(player, mountAnim, 0, 0x14);
  235.    SetMountWait(player, GetKeyLen(mountAnim));
  236.  
  237.    // Clear Lightsaber flag, and enable activation messages.
  238.    jkClearFlags(player, 0x5);
  239.    SetCurWeapon(player, GetWeaponBin(14));
  240.    SetMountWait(player, GetKeyLen(mountAnim));
  241.  
  242.    Return;
  243.  
  244. # ........................................................................................
  245.  
  246. deselected:
  247.    player = GetSourceRef();
  248.  
  249.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  250.  
  251.    holsterWait = GetKeyLen(holsterAnim);
  252.    SetMountWait(player, holsterWait);
  253.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  254.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  255.    if(selectTrack != -1)
  256.    {
  257.       jkStopPOVKey(player, selectTrack, 0);
  258.       selectTrack = -1;
  259.    }
  260.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  261.    KillTimerEx(0);
  262.  
  263.    if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  264.    {
  265.       jkStopPOVKey(player, prePOVThrowTrack, 0);
  266.       StopKey(player, preThrowTrack, 0);
  267.       preThrowTrack = -1;
  268.       prePOVThrowTrack = -1;
  269.    }
  270.  
  271.    Return;
  272.  
  273. # ........................................................................................
  274.  
  275. autoselect:
  276.    selectMode = GetSenderRef();
  277.    player = GetSourceRef();
  278.  
  279.    // If the player has ammo
  280.    if(GetInv(player, GetWeaponBin(14)) != 0)
  281.    {
  282.  
  283.       // query for ammo
  284.       if(selectMode == -1)
  285.       {
  286.          ReturnEx(399.0);
  287.          Return;
  288.       }
  289.  
  290.       if((selectMode == 0) && !(GetAutoPickup() & 2))
  291.       {
  292.          ReturnEx(399.0);
  293.          Return;
  294.       }
  295.  
  296.       if((selectMode == 1) && !(GetAutoSwitch() & 2))
  297.       {
  298.          ReturnEx(399.0);
  299.          Return;
  300.       }
  301.  
  302.       if((selectMode == 2) && !(GetAutoPickup() & 2))
  303.       {
  304.          ReturnEx(399.0);
  305.          Return;
  306.       }
  307.  
  308.       ReturnEx(-2.0);
  309.       Return;
  310.  
  311.    }
  312.    else
  313.    {
  314.       ReturnEx(-1.0);
  315.    }
  316.  
  317.    Return;
  318.  
  319. # ........................................................................................
  320.  
  321. newplayer:
  322.    if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  323.    {
  324.       jkStopPOVKey(player, prePOVThrowTrack, 0);
  325.       StopKey(player, preThrowTrack, 0);
  326.       preThrowTrack = -1;
  327.       prePOVThrowTrack = -1;
  328.    }
  329.    Return;
  330.  
  331. # ........................................................................................
  332.  
  333. user0:
  334.     victim = GetParam(0);
  335.     SetActorFlags(victim, 0x800);
  336.     SetTimerEx(GetParam(1), 11, GetThingSignature(victim), victim);
  337.     return;
  338.  
  339. # ........................................................................................
  340.  
  341. end
  342.